package org.lzy.shop.viewmodel.repository.lmpl

import org.lzy.shop.network.KtorApiService
import org.lzy.shop.response.CouponResponse
import org.lzy.shop.viewmodel.repository.BaseRepository
import org.lzy.shop.viewmodel.repository.CouponRepository

class CouponRepositoryImpl : BaseRepository(), CouponRepository {

    override suspend fun getCoupons(): CouponResponse? {
        return safeApiCall {
            val response = KtorApiService.getCoupon()
            handleResponse(response)
        }
    }

    override suspend fun getMyCoupons(page: Int, size: Int): CouponResponse? {
        return safeApiCall {
            val response = KtorApiService.getMyCoupon(page, size)
            handleResponse(response)
        }
    }

    override suspend fun receiveCoupon(couponId: Int?): String? {
        return safeApiCall {
            val response = KtorApiService.couponReceive(couponId)
            handleResponse(response)
        }
    }

}